package io.renren.com.qywt.excel.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

public class ProblemTypeConverter implements Converter<Integer> {
    @Override
    public Class<Integer> supportJavaTypeKey() {
        return Integer.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        if(cellData.getStringValue().equals("催单")){
            return 0;
        }else if(cellData.getStringValue().equals("拦截")){
            return 1;
        }else if(cellData.getStringValue().equals("无理由退回")){
            return 2;
        }else if(cellData.getStringValue().equals("破损退回")){
            return 3;
        }else if(cellData.getStringValue().equals("破损签收")){
            return 4;
        }else if(cellData.getStringValue().equals("错发")){
            return 5;
        }else if(cellData.getStringValue().equals("错发退回")){
            return 6;
        }else if(cellData.getStringValue().equals("丢件")){
            return 7;
        }else if(cellData.getStringValue().equals("修改收件信息")){
            return 8;
        }else if(cellData.getStringValue().equals("核实包裹重量")){
            return 9;
        }else if(cellData.getStringValue().equals("虚假签收")){
            return 10;
        }else if(cellData.getStringValue().equals("丢失少件")){
            return 11;
        }else if(cellData.getStringValue().equals("其它问题")){
            return 12;
        }else if(cellData.getStringValue().equals("走件异常")){
            return 13;
        }else if(cellData.getStringValue().equals("商品破损/瑕疵问题")){
            return 14;
        }else if(cellData.getStringValue().equals("双面单")){
            return 15;
        }else if(cellData.getStringValue().equals("退件签收核实")){
            return 16;
        }else if(cellData.getStringValue().equals("空包")){
            return 17;
        }else if(cellData.getStringValue().equals("多发")){
            return 18;
        }else{
            return 19;
        }
    }

    @Override
    public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        if(value == 0){
            return new WriteCellData<>("催单");
        }else if(value == 1){
            return new WriteCellData<>("拦截");
        }else if(value == 2){
            return new WriteCellData<>("无理由退回");
        }else if(value == 3){
            return new WriteCellData<>("破损退回");
        }else if(value == 4){
            return new WriteCellData<>("破损签收");
        }else if(value == 5){
            return new WriteCellData<>("错发");
        }else if(value == 6){
            return new WriteCellData<>("错发退回");
        }else if(value == 7){
            return new WriteCellData<>("丢件");
        }else if(value == 8){
            return new WriteCellData<>("修改收件信息");
        }else if(value == 9){
            return new WriteCellData<>("核实包裹重量");
        }else if(value == 10){
            return new WriteCellData<>("虚假签收");
        }else if(value == 11){
            return new WriteCellData<>("丢失少件");
        }else if(value == 12){
            return new WriteCellData<>("其它问题");
        }else if(value == 13){
            return new WriteCellData<>("走件异常");
        }else if(value == 14){
            return new WriteCellData<>("商品破损/瑕疵问题");
        }else if(value == 15){
            return new WriteCellData<>("双面单");
        }else if(value == 16){
            return new WriteCellData<>("退件签收核实");
        }else if(value == 17){
            return new WriteCellData<>("空包");
        }else if(value == 18){
            return new WriteCellData<>("多发");
        }else {
            return new WriteCellData<>("其它问题");
        }
    }
}
